cmake_minimum_required(VERSION 4.0)
project(ltgsql LANGUAGES C)

set(CMAKE_C_STANDARD 27)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -O2 -g")

# 包含目录
include_directories(src/include)

# 源文件
file(GLOB_RECURSE CORE_SRCS "src/core/*.c")
file(GLOB_RECURSE NETWORK_SRCS "src/network/*.c")
file(GLOB_RECURSE UTILS_SRCS "src/utils/*.c")
set(MAIN_SRC src/main.c
        src/utils/memory.c
        src/utils/memory.c
        src/include/storage.h
        src/utils/memory.c
        src/utils/input_win.c)

# 主目标
add_executable(ltgsql ${MAIN_SRC} ${CORE_SRCS} ${NETWORK_SRCS} ${UTILS_SRCS}
        src/utils/memory.c
        src/utils/input_win.c)
target_link_libraries(ltgsql pthread m rt readline)

# 安装目标
install(TARGETS ltgsql DESTINATION bin)

# 测试
enable_testing()
add_subdirectory(tests)
add_subdirectory(benchmarks)